package com.changyue.db;

import com.changyue.greendao.gen.HistoryDataEntityDao;
import com.changyue.greendao.gen.TestDataEntityDao;
import com.changyue.activity.history.entity.HistoryDataEntity;
import com.changyue.activity.history.entity.TestDataEntity;

/**
 * 存放DaoUtils
 */
public class DaoUtilsStore {
    private volatile static DaoUtilsStore instance = new DaoUtilsStore();

    private CommonDaoUtils<HistoryDataEntity, Long> historyDaoUtils;
    private CommonDaoUtils<TestDataEntity, Long> testDataDaoUtils;

    public static DaoUtilsStore getInstance() {
        if (instance == null) {
            instance = new DaoUtilsStore();
        }
        return instance;
    }

    private DaoUtilsStore() {
        DaoManager mManager = DaoManager.getInstance();

        HistoryDataEntityDao boardEntityDao = mManager.getDaoSession().getHistoryDataEntityDao();
        historyDaoUtils = new CommonDaoUtils<>(HistoryDataEntity.class, boardEntityDao);

        TestDataEntityDao testDataEntityDao = mManager.getDaoSession().getTestDataEntityDao();
        testDataDaoUtils = new CommonDaoUtils<>(TestDataEntity.class, testDataEntityDao);
    }

    public CommonDaoUtils<HistoryDataEntity, Long> getHistoryDaoUtils() {
        return historyDaoUtils;
    }

    public CommonDaoUtils<TestDataEntity, Long> getTestDataDaoUtils() {
        return testDataDaoUtils;
    }
}